package codeTop;

import java.util.ArrayList;
import java.util.List;

public class q46 {
    public List<List<Integer>> permute(int[] nums) {
        dfs(nums,new ArrayList<>());
        return res;
    }
    List<List<Integer>> res = new ArrayList<>();
    void dfs(int[] nums,List<Integer> list){
        if (list.size() == nums.length) {
            res.add(List.copyOf(list));
            return;
        }
        for (int i = 0; i < nums.length; i++) {
            if (nums[i] != 11) {
                int temp = nums[i];
                list.add(nums[i]);
                nums[i]=11;
                dfs(nums,list);
                nums[i] = temp;
                list.remove(list.size()-1);
            }
        }
    }
}
